<extend name="Public:common"/>
<block name="css">
    <style>
        <link rel="stylesheet" href="__STATIC__/layui/css/layui.css"  media="all">
        .left{width:20%; vertical-align: middle;}
        .right{text-align:left;width:80%;}
        td{vertical-align: middle;}
        label{margin-left:15px;padding:5px;}
    </style>
</block>
<block name="content">
     <div class="container-fluid">



         <div class="tabbable">



             <div class="row" style="padding:10px;">
                <span style="cursor:pointer;margin-right:10px;" class="btn btn-primary pull-right" onclick="choseOk();">已经填好</span>
             </div>


             <div class="tab-content">



                 <!--<table class="table table-striped table-bordered table-hover table-condensed text-center">
                     <tbody>
                         <tr>
                             <td class="left">
                                <h4>成本价:</h4>
                             </td>
                             <td class="right">
                                 <div class="row">
                                     <div class="col-md-4 col-xs-4"><label  >成人成本价:</label> <b>{$lineInfo.adult_cost}</b> </div>
                                     <div class="col-md-4 col-xs-4"><label  >儿童成本价:</label> {$lineInfo.child_cost}</div>
                                     <div class="col-md-4 col-xs-4"><label  >老人成本价:</label>{$lineInfo.oldman_cost} </div>
                                 </div>
                             </td>
                         </tr>
                     </tbody>
                 </table>-->


                 <table class="table table-striped table-bordered table-hover table-condensed text-center">
                     <tbody>
                        <tr>
                            <th colspan="2"><h4>给运营商的特殊日期价格:</h4> 勾选日期后显示特殊日期编辑,编辑好确认 </th>
                        </tr>
                         <volist name="day" id="vo">
                             <tr>
                                 <td class="left">
                                     <label for="day_{$vo}"><b>{$vo}</b></label>
                                     <input type="checkbox" id="day_{$vo}" value="{$vo}" class="day">
                                 </td>
                                 <td class="right">
                                    <div class="row item_{$vo}" style="display:none;">
                                        <div class="col-md-4 col-xs-4"><label class="label label-info" >成人价:</label>  <input type="text" name="adult" class="adult" placeholder="请输入成人价" value="" onkeyup="clearNoNum(this)" onafterpaste="clearNoNum(this)"></div>
                                        <div class="col-md-4 col-xs-4"><label class="label label-info" >儿童价:</label> <input type="text" name="child" class="child" placeholder="请输入儿童价" value="" onkeyup="clearNoNum(this)" onafterpaste="clearNoNum(this)"></div>
                                        <div class="col-md-4 col-xs-4"><label class="label label-info" >老人价:</label> <input type="text" name="oldman" class="oldman" placeholder="请输入老人价" value="" onkeyup="clearNoNum(this)" onafterpaste="clearNoNum(this)"></div>
                                    </div>
                                 </td>
                             </tr>
                         </volist>
                     </tbody>
                 </table>
             </div>
         </div>
     </div>
</block>
<block name="js">
    <script type="text/javascript" src="__STATIC__/layer/layer.js"></script>
    <script>


        /**
         * input限制2位小数输入
         */
        function clearNoNum(obj)
        {
            //先把非数字的都替换掉，除了数字和.
            obj.value = obj.value.replace(/[^\d.]/g,"");
            //必须保证第一个为数字而不是.
            obj.value = obj.value.replace(/^\./g,"");
            //保证只有出现一个.而没有多个.
            obj.value = obj.value.replace(/\.{2,}/g,".");
            //保证.只出现一次，而不能出现两次以上
            obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
        }



        $('body').on('change','.day',function () {
            var isChose=$(this).is(":checked");
            var val=$(this).val();
            if(isChose){
                $('.item_'+val).show();
            }else{
                $('.item_'+val).hide();
            }
        });


        function choseOk(){
            var info=[];
             $('.day').each(function () {
                 if($(this).is(':checked')){
                     var val=$(this).val();
                     var adult=$('.item_'+val).find('.adult').val();
                     var child=$('.item_'+val).find('.child').val();
                     var oldman=$('.item_'+val).find('.oldman').val();
                     if(adult&&child&&oldman&&$('.item_'+val).is(':visible')){
                         var item={day:val,adult:adult,child:child,oldman:oldman};
                         info.push(item);
                     }
                 }
             });
             if(info.length<=0){
                 layer.msg('请填写完整数据');
                 alert('请填写完整数据');
                 return false;
             }
            parent.{:I('back')}(JSON.stringify(info));
        }
    </script>
</block>